package com.xzx;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import lombok.extern.slf4j.Slf4j;

import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;

/**
 *
 * @author xinzhixuan
 * @version 1.0
 * @date 2025/9/19 18:31
 */
@Slf4j
public class Main {
    public static void main(String[] args) throws PropertyVetoException, SQLException {
        ComboPooledDataSource cpds = new ComboPooledDataSource(true);
        cpds.setJdbcUrl("jdbc:mysql://localhost:3306/jdbc");
        cpds.setDriverClass("com.mysql.cj.jdbc.Driver");
        cpds.setUser("root");
        cpds.setPassword("Admin_111");
        cpds.setMaxPoolSize(10);
        cpds.setMinPoolSize(1);
        cpds.setAcquireIncrement(1);
        cpds.setInitialPoolSize(1);
        cpds.setMaxIdleTime(100);
        cpds.setMaxStatements(180);
        cpds.setCheckoutTimeout(3000);
        cpds.setIdleConnectionTestPeriod(10);
        cpds.setNumHelperThreads(100);
        Connection connection = cpds.getConnection();
        log.info("connection: {}", connection);
    }
}